// 系统调用操作
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main()
{
    // 写方式打开
    int wfd = open("linux.txt",O_CREAT|O_WRONLY|O_TRUNC,0666);
    char wmessage[] = "linux so easy!\n";
    write(wfd,wmessage,strlen(wmessage));
    //关闭写

    int rfd = open("linux.txt",O_RDONLY);
    lseek(rfd,0,SEEK_SET);
    char rmessage[128];
    read(rfd,rmessage,sizeof(rmessage));
    write(1,rmessage,strlen(rmessage));
    close(wfd);

    close(rfd);
}